package org.tulkas.robot.log;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class TulkasLoggerFactory implements ILoggerFactory {
	Map<String, TulkasLogger> logMap = new ConcurrentHashMap<String, TulkasLogger>();

	/* (non-Javadoc)
	 * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String)
	 */
	public Logger getLogger(String name) {
		TulkasLogger logger = null;
		if (!logMap.containsKey(name)) {
			synchronized (this) {
				if (!logMap.containsKey(name)) {
					logger = new TulkasLogger(name);
					logMap.put(name, logger);
				}
			}
		} else {
			logger = logMap.get(name);
		}
		return logger;
	}

}
